package main

import (
	"fmt"
	"sync"
	"time"
)

var sync_wait sync.WaitGroup

func test(num int) {
	for i := 1; i < 6; i++ {
		fmt.Printf("协程{%d}输入第{%d}条数据\n", num, i)
		time.Sleep(time.Millisecond * 20)
	}
	sync_wait.Done()
}

func main() {
	for i := 1; i < 21; i++ {
		sync_wait.Add(1)
		go test(i)
	}

	sync_wait.Wait()
	fmt.Println("关闭主线程")
}
